
/*
 * Copyright 2002-2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2014原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.format;

import java.lang.annotation.Annotation;
import java.util.Set;

/**
 * A factory that creates formatters to format values of fields annotated with a particular
 * {@link Annotation}.
 *
 * <p>For example, a {@code DateTimeFormatAnnotationFormatterFactory} might create a formatter
 * that formats {@code Date} values set on fields annotated with {@code @DateTimeFormat}.
 *
 * @author Keith Donald
 * @since 3.0
 * @param <A> the annotation type that should trigger formatting
 */
/**
 *一个工厂，它创建格式化程序来格式化用特定
 *｛@link注释｝。
 *
 *＜p＞例如，｛@code DateTimeFormatAnnotationFormatterFactory｝可能会创建一个格式化程序
 *格式化在用｛@code@DateTimeFormat｝注释的字段上设置的｛@code Date｝值。
 *
 *@作者Keith Donald
 *@自3.0起
 *@param＜A＞应该触发格式化的注释类型
 */
public interface AnnotationFormatterFactory<A extends Annotation> {

	/**
	 * The types of fields that may be annotated with the &lt;A&gt; annotation.
	 */
	/**
	 *可以用&lt；答：；注释。
	 */
	Set<Class<?>> getFieldTypes();

	/**
	 * Get the Printer to print the value of a field of {@code fieldType} annotated with
	 * {@code annotation}.
	 * <p>If the type T the printer accepts is not assignable to {@code fieldType}, a
	 * coercion from {@code fieldType} to T will be attempted before the Printer is invoked.
	 * @param annotation the annotation instance
	 * @param fieldType the type of field that was annotated
	 * @return the printer
	 */
	/**
	 *让打印机打印用注释的｛@code fieldType｝字段的值
	 *｛@code注释｝。
	 *＜p＞如果打印机接受的类型T不可分配给｛@code fieldType｝，则
	 *在调用打印机之前，将尝试从｛@code fieldType｝强制到T。
	 *@param annotation注释实例
	 *@param fieldType注释的字段类型
	 *@退回打印机
	 */
	Printer<?> getPrinter(A annotation, Class<?> fieldType);

	/**
	 * Get the Parser to parse a submitted value for a field of {@code fieldType}
	 * annotated with {@code annotation}.
	 * <p>If the object the parser returns is not assignable to {@code fieldType},
	 * a coercion to {@code fieldType} will be attempted before the field is set.
	 * @param annotation the annotation instance
	 * @param fieldType the type of field that was annotated
	 * @return the parser
	 */
	/**
	 *让Parser为｛@code fieldType｝的字段解析提交的值
	 *用{@code annotation}注释。
	 *＜p＞如果解析器返回的对象不可分配给{@code fieldType}，
	 *在设置字段之前，将尝试强制执行{@code fieldType}。
	 *@param annotation注释实例
	 *@param fieldType注释的字段类型
	 *@返回解析器
	 */
	Parser<?> getParser(A annotation, Class<?> fieldType);

}
